//
//  PingJIACELL.m
//  QinghaiTourism
//
//  Created by QianXiaoShu on 16/3/10.
//  Copyright © 2016年 QianXiaoShu. All rights reserved.
//

#import "PingJIACELL.h"
#import "UIView+SDAutoLayout.h"
CGFloat rotHeight = 50;

@implementation PingJIACELL

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self= [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self initInterface];//初始化加载到cell上的控件
           }
    return self;
}
-(void)initInterface{
    
    //配置_logoImageVIew
    _logoImageVIew = [[UIImageView alloc] init];
    //_logoImageVIew.frame = CGRectMake(10, 10, 40, 40);
    _logoImageVIew.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:_logoImageVIew];
    
    _name = [[UILabel alloc]init];
    _name.text = @"溺水放松丰厚啊首发";
    //_name.frame = CGRectMake(50, 10, 300, 20);
    _name.textColor = [UIColor darkGrayColor];
    _name.font = [UIFont  systemFontOfSize:14];
    [self.contentView addSubview:_name];
    
    _star  = [[ZHStarView alloc]init];
    _star.starSize = 15;
  //  _star.frame = CGRectMake(50, 30, kWindowWidth/4, 20);
    [self.contentView addSubview:_star];
    
    _titleLabel = [[UILabel alloc]init];
    _titleLabel.font = [UIFont  systemFontOfSize:13];
  //  _titleLabel.frame = CGRectMake(50, 50, kWindowWidth-40-10, 20);
    _titleLabel.numberOfLines = 0;
    [self.contentView addSubview:_titleLabel];
    
    
    
    
    _timeLable = [[UILabel alloc]init];
    _timeLable.text = @"dsffdf342424";
//    _timeLable.frame = CGRectMake(kWindowWidth/2, 0, kWindowWidth/2, 20);
    _timeLable.textAlignment = NSTextAlignmentRight;
    _timeLable.font = [UIFont  systemFontOfSize:13];
    [self.contentView addSubview:_timeLable];
    

    
    _logoImageVIew.sd_layout.leftSpaceToView(self.contentView,10).topSpaceToView(self.contentView,10).widthIs(40).heightIs(40);
   
    _name.sd_layout.leftSpaceToView(_logoImageVIew,0).topSpaceToView(self.contentView,10).widthIs(300).heightIs(20);
   
    _star.sd_layout.leftEqualToView(_name).topSpaceToView(_name,0).widthIs(kWindowWidth*1/4).heightIs(20);

    _titleLabel.sd_layout.leftEqualToView(_name).topSpaceToView(_star,10).rightSpaceToView(self.contentView,10).autoHeightRatio(0);
  
    _timeLable.sd_layout.rightSpaceToView(self.contentView,10).centerYEqualToView(_name).heightIs(20);

    
    
    
    

    _logoImageVIew.layer.cornerRadius = 20;
    _logoImageVIew.clipsToBounds = YES;

    [self setupAutoHeightWithBottomView:_titleLabel bottomMargin:10];

    
}
-(void)layoutSubviews{
    [super layoutSubviews];
    [_star setShowStar:[self.evaObj.eavscore integerValue]*20];
 
    _titleLabel.text = [NSString stringWithFormat:@"%@",self.evaObj.content];

    [_titleLabel sizeToFit];

    
  
    _name.text = self.evaObj.nickname;
   
    _timeLable.text = [QHTools stringWithHHMMSSFromTimeInterVerString:[NSString stringWithFormat:@"%ld",self.evaObj.evatTime/1000]];
    [_logoImageVIew sd_setImageWithURL:[NSURL URLWithString:self.evaObj.headUrl] placeholderImage:DEFAULT_IMAGE];
   
    
//   rotHeight = CGRectGetHeight(_titleLabel.frame) +50;




}

+(CGFloat)rowHeight{
    
    return rotHeight;
}

@end
